﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gencode.Gengui.Wizzard;

namespace Gencode.PrsUtil.Dialog.Stammdaten.PersonWizard
{
	public partial class PersonData : Gencode.Gengui.Wizzard.WizzardControl
	{
		string _mandid;

		public PersonData(string previousControl, string nextControl, WizzardDialog controler, string mandid)
			: base(previousControl, nextControl, controler)
		{
			InitializeComponent();

			_mandid = mandid;
		}

		public override bool MoveNext()
		{
			Gencode.PrsCommon.Data.Person.SimplePersonData data = new Gencode.PrsCommon.Data.Person.SimplePersonData(_mandid);

			if (txtName.Text.CompareTo(string.Empty) == 1)
				data.Name = txtName.Text;
			else
			{
				MarkNotFilledFields();
				return false;
			}

			if (txtVorname.Text.CompareTo(string.Empty) == 1)
				data.Vorname = txtVorname.Text;
			else
			{
				MarkNotFilledFields();
				return false;
			}

			if (txtStrasse.Text.CompareTo(string.Empty) == 1)
				data.Strasse = txtStrasse.Text;
			else
			{
				MarkNotFilledFields();
				return false;
			}

			data.Strassennummer = txtStrNr.Text;
			data.Postfach = txtPostfach.Text;

			if (txtPlz.Text.CompareTo(string.Empty) == 1)
				data.PLZ = txtPlz.Text;
			else
			{
				MarkNotFilledFields();
				return false;
			}

			if (txtOrt.Text.CompareTo(string.Empty) == 1)
				data.Ort = txtOrt.Text;
			else
			{
				MarkNotFilledFields();
				return false;
			}

			data.TelefonPrivat = txtTelP.Text;
			data.TelefonNatel = txtTelN.Text;
			data.Email = txtEmail.Text;

			Controler.DataObjects.AddType(data, typeof(Gencode.PrsCommon.Data.Person.SimplePersonData));


			return base.MoveNext();
		}

		public void MarkNotFilledFields()
		{
			txtName.BackColor = Color.Yellow;
			txtVorname.BackColor = Color.Yellow;
			txtStrasse.BackColor = Color.Yellow;
			txtPlz.BackColor = Color.Yellow;
			txtOrt.BackColor = Color.Yellow;
		}
	}
}
